#include "stdafx.h"
#include "ShaderManager.h"

#include "ShaderTextured.h"
#include "ShaderPhong1PL.h"
#include "ShaderNormal1PL.h"
#include "ShaderAmbient.h"
#include "ShaderShadowVolume.h"

using namespace mgfx;

Shader * ShaderManager::getShader(ShaderID id)
{
	assert(mShaders.find(id) != mShaders.end());
	return mShaders[id];
}

void ShaderManager::init(ID3D10Device* device)
{
	mShaders[ShaderID::TEXTURED] = new ShaderTextured;
	mShaders[ShaderID::PHONG_1PL] = new ShaderPhong1PL;
	mShaders[ShaderID::NORMAL_1PL] = new ShaderNormal1PL;
	mShaders[ShaderID::AMBIENT] = new ShaderAmbient;
	mShaders[ShaderID::SHADOW_VOLUME] = new ShaderShadowVolume;

	for(ShaderMap::iterator it = mShaders.begin() ; it != mShaders.end() ; ++it)
	{
		bool result = it->second->load(device, it->first);
		assert(result);
	}
}

void ShaderManager::deinit()
{
	for(ShaderMap::iterator it = mShaders.begin() ; it != mShaders.end() ; ++it)
		delete it->second;
}